package com.gang.music.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.gang.music.system.entity.UserRole;
import com.gang.music.system.mapper.UserRoleMapper;
import com.gang.music.system.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gang
 * @since 2017-10-30
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
	
	@Autowired
	private UserRoleMapper userRoleMapper;

	@Override
	public void insert(Long userId, List<Integer> roleIdList) {
		
		userRoleMapper.batchInsert(userId, roleIdList);
	}

	@Override
	public void update(Long userId, List<Integer> roleIdList) {
		
		userRoleMapper.deleteByUserId(userId);
		userRoleMapper.batchInsert(userId, roleIdList);
	}
}
